//
//  WTPerGiftPageImageCell.m
//  66TV
//
//  Created by ben on 16/8/8.
//  Copyright © 2016年 shifeng. All rights reserved.
//

#import "WTPerGiftPageImageCell.h"
#import "UIColor+WTExtend.h"
#import "UIImageView+WebCache.h"
#import "UIImage+WTExtend.h"

@interface WTPerGiftPageImageCell ()

@end

@implementation WTPerGiftPageImageCell

- (void)awakeFromNib {
    [super awakeFromNib];

    self.selectedView.layer.borderColor = [UIColor themeColor].CGColor;
    self.selectedView.layer.borderWidth = 1;
    self.selectedView.hidden = YES;
    self.countLabel.hidden = YES;
}

- (void)setGiftModel:(WTChatRoomGiftModel *)giftModel{
    
    if(giftModel.selectedStatus){
        
        self.selectedView.hidden = NO;
        self.countLabel.hidden = NO;
        NSInteger index = giftModel.tagCount % [WTChatRoomGiftModel giftCountList].count;
        NSInteger giftCount = [[WTChatRoomGiftModel giftCountList][index] integerValue];
        self.countLabel.text = [NSString stringWithFormat:@"%zd",giftCount];
        giftModel.tagCount++;
        giftModel.gift_count = giftCount;
        
    }else {
        
        self.selectedView.hidden = YES;
        self.countLabel.hidden = YES;
        giftModel.tagCount = 0;
        giftModel.gift_count = 0;
    }
    
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:giftModel.gift_image_url] placeholderImage:[UIImage wt_imageWithName:@"wt_avatar"]];
    [self.priceLabel setText:[NSString stringWithFormat:@"%zd 萝卜",giftModel.gift_price]];
    [self.nameLabel setText:giftModel.gift_name];
}

@end
